<?php

// Fjerne feilmeldinger for alle brukere untatt administratorer
if(!is_admin() && !is_user_logged_in() && current_user_can('switch_themes')) error_reporting(0);

// Style for TinyMCE editor
add_editor_style('style-editor.css');

add_action('init', 'gevir_init');
add_action('wp_print_scripts', 'gevir_wp_print_scripts');
add_action('wp_print_footer_scripts', 'gevir_wp_print_footer_scripts');

function gevir_init() {

	if(!is_admin()) {
		wp_deregister_script('jquery');

		// Register scripts
		wp_register_script('jquery-google', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js', false, '1.6.2', true);
		wp_register_script('jquery', get_bloginfo('template_directory') .'/gevir/js/jquery.fix.js', array('jquery-google'), '1.0', true);
		wp_register_script('gevir_core', get_bloginfo('template_directory') .'/gevir/js/gevircore.js', array('jquery'), '1.0', true);
		wp_register_script('theme_core', get_bloginfo('template_directory') .'/js/core.js', array('jquery'), '1.0', true);
		
		// Enqueue scripts
		wp_enqueue_script('modernizr');
		wp_enqueue_script('plugins');
		wp_enqueue_script('gevir_core');
		wp_enqueue_script('theme_core');
		
		// Register styles
		wp_register_style('gevir_reset', get_bloginfo('template_directory') .'/gevir/reset.css', NULL, '1.0', 'all');
		wp_register_style('gevir_core', get_bloginfo('template_directory') .'/style.css', array('gevir_reset'), '1.0', 'all');
		wp_register_style('gevir_media', get_bloginfo('template_directory') .'/gevir/media.css', array('gevir_core'), '1.0', 'all');
		
		// Enqueueu styles
		wp_enqueue_style('gevir_reset');
		wp_enqueue_style('gevir_core');
		wp_enqueue_style('gevir_media');
	}
}
function gevir_wp_print_scripts() {
	if(!is_admin()) {
?>
<script type="text/javascript">
/* <![CDATA[ */
URL = '<?php bloginfo('url'); ?>';
TEMPLATE_DIRECTORY = '<?php bloginfo('template_directory'); ?>';
/* ]]> */
</script>
<?php
	}
}
function gevir_wp_print_footer_scripts() {
	if(!is_admin()) {
		?>
<!--[if lt IE 7 ]>
	<script src="<?php bloginfo('template_directory'); ?>/gevir/js/libs/dd_belatedpng.js"></script>
	<script> DD_belatedPNG.fix('img, .png_bg');</script>
<![endif]-->
        <?php
	}
}

// FACEBOOK
add_action("wp_footer", "facebook_footer");
function facebook_footer() {
	echo '<div id="fb-root"></div><script src="http://connect.facebook.net/nb_NO/all.js#appId=178606732200199&amp;xfbml=1"></script>' . "\n";
}

add_filter("language_attributes", "facebook_html");
function facebook_html($language_attributes) {
	$language_attributes .= ' xml:lang="nn" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://developers.facebook.com/schema/"';
	return $language_attributes;
}